<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>用户中心-{$tpshop_config['shop_info_store_title']}</title>
    <meta name="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
    <meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
    <link rel="stylesheet" href="__STATIC__/css/index.css" type="text/css">
    <link rel="stylesheet" href="__STATIC__/css/security_set.css">
    <link rel="stylesheet" href="__STATIC__/css/btn.css">
<link rel="stylesheet" href="__STATIC__/css/user.css" type="text/css">
    <script src="__STATIC__/js/jquery-1.10.2.min.js"></script>
    <script src="__STATIC__/js/slider.js"></script>
</head>
<body>
<include file="Public/header" />
<include file="Public/topnav" />

<div class="page_pad">
  <div class="page_margin">
    <div class="page_radius">
      <div class="page_padin">
        <div class="regpage" style="padding:100px 0;">
          <div class="reg_tit"><div class="pad">验证身份</div></div>
          <select id="verify-type-selector" style="width:523px; border:1px solid #DCDCDC; color:#757575; font-size:14px; height:52px;display:none;">
            <if condition="strstr($_POST['username'],'@')">
            <option value="email" selected alias-value="2">邮箱验证</option>
            <else / >
            <option value="phone" selected alias-value="1">手机验证</option>
            </if>
          </select>
<!--

            <if condition="$v_type1 eq 'phone'">
                <tr>
                    <td><input class="zc-text zc_u" type="text" name="mobile" id="mobile" onBlur="chkuser()" placeholder="已验证邮箱：{$userinfo.email}" readonly/>
                    </td>
                </tr>
                <elseif condition="$v_type1 eq 'email'"/>
                <tr>
                    <td><input class="zc-text zc_u" type="text" name="mobile" id="mobile" onBlur="chkuser()" placeholder="已验证手机号码：{$userinfo.mobile}" readonly/>
                        <input type="hidden" id="mobile_c" value="{$userinfo.mobile}" />
                    </td>
                </tr>
            </if>
-->



          
            <if condition="$v_type1 eq 'phone'">
              <div class="ginput_div ginput_div_icon"><i class="icon-shouji1"></i><input class="ginput" type="text" name="mobile" id="mobile" onBlur="chkuser()" placeholder="已验证手机号码：{$userinfo.mobile}" readonly /><input type="hidden" id="mobile_c" value="{$userinfo.mobile}" /></div>
             <elseif condition="$v_type1 eq 'email'"/>
             <div class="ginput_div ginput_div_icon"><i class="icon-xinfeng"></i><input class="ginput" type="text" name="mobile" id="mobile" onBlur="chkuser()" placeholder="已验证邮箱：{$userinfo.email}" readonly/><input type="hidden" id="email_c" value="{$userinfo.email}" /></div>
          </if>
          
          <div class="ginput_div ginput_div_icon">
            <div class="fl"><i class="icon-yanzhengma2"></i><input class="ginput" name="tpcode" id="tpcode" type="text" placeholder="短信验证码" /></div>
            <div class="fr"><button type="button" class="reg_send" id="count_down1" onClick="send_sms_reg_code()">获取短信验证码</button></div>
            <div class="clear"></div>
          </div>
          
          <div class="ginput_div"><button type="submit" class="login_sub" onclick="setpwd()">下一步</button></div>
        </div>
        
        <input type="hidden" id="username" value="{$userinfo.username}">
      </div><!--page_padin-->
    </div><!--page_radius-->
  </div><!--page_margin-->
</div><!--page_pad-->

<!--<div id="user_container">
	<div id="user_login">
		<div class="wel-log">验证身份</div>
			  <div class="login-x">
                <div>
                    <table class="pa-10-0" width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td>
                            </td>
                        </tr>
                        <if condition="$v_type1 eq 'email'">
                            <tr>
                                <td><input class="zc-text zc_u" type="text" name="mobile" id="mobile" onBlur="chkuser()" placeholder="已验证邮箱：{$userinfo.email}" readonly/>
                                </td>
                            </tr>
                            <elseif condition="$v_type1 eq 'phone'"/>
                            <tr>
                                <td><input class="zc-text zc_u" type="text" name="mobile" id="mobile" onBlur="chkuser()" placeholder="已验证手机号码：{$userinfo.mobile}" readonly/>
                                    <input type="hidden" id="mobile_c" value="{$userinfo.mobile}" />
                                </td>
                            </tr>
                        </if>





                    <!--   <if condition="$userinfo['mobile'] neq ''">
                        <tr>
                            <td><input class="zc-text zc_u" type="text" name="mobile" id="mobile" onBlur="chkuser()" placeholder="已验证手机号码：{$userinfo.mobile}" readonly/>
                            <input type="hidden" id="mobile_c" value="{$userinfo.mobile}" />
                            </td>
                        </tr>
                        </if>

                       <if condition="$userinfo['email'] neq ''">
                        <tr>
                            <td><input class="zc-text zc_u" type="text" name="mobile" id="mobile" onBlur="chkuser()" placeholder="已验证邮箱：{$userinfo.email}" readonly/>
                            </td>
                        </tr>
                       </if>-->

                        <!--<tr>
                            <td>
                                <input class="ginput" name="tpcode" id="tpcode" type="text" placeholder="短信验证码" />
                                <input type="button" class="" style="width: 105px;height:52px;margin-top:0; border:none; background:#000; float:right; color:#fff;" id="sendSms" onclick="send_sms_reg_code()" value="获取验证码">
                            </td>
                        </tr>

                        <tr>
                            <td><input type="button" class="login" id="fx_next" onclick="setpwd()" value="下一步"><br ><br ><br ><br ><br ><br ></td>
                        </tr>-->
                    </table>
                </div>
            </div>
	</div>
</div>-->

<include file="Public/footer" />
<script>
 // 发送手机短信
    function send_sms_reg_code(){
        var mobile = $('#mobile_c').val();
        var email = $('#email_c').val();
        var type = $('#verify-type-selector').val();

        if(!checkMobile(mobile)&&!checkEmail(email)){
            // layer.alert('请输入正确的手机号码', {icon: 2});// alert('请输入正确的手机号码');
            $.artTip('手机号码/邮箱不正确.', 800);
            return;
        }

        var url = "/index.php?m=Home&c=User&a=send_sms_reg_code";
//        var url = "{:U('Home/User/send_sms_code')}";

		$.ajax({
		  type:"post",
		  url:url,
		  data:{"mobile":mobile,"email":email,"type":type},
		  dataType:"json",
		  
		  success:function(data)
		  {

		      if(data.status!=1){
                  $.artTip(data.msg, 800);
                  return false;
              }
			  //发送成功
			  if(data.status=1)
			  {
				  counttime = "{$sms_time_out}"; // 手机短信超时时间
				  countdown('#count_down1',counttime);
			  }
		  }
		});
    }
	
	
	function countdown(divid,counttime)
	{
		$(divid).attr("disabled","disabled");
		$(divid).addClass("reg_send_off");
		
		counttime--;
        if(counttime<=-1)
        {
			$(divid).removeAttr("disabled");
			$(divid).removeClass("reg_send_off");
            $(divid).html("获取短信验证码");
            return false;
        }

        $(divid).html(counttime+'秒');

        setTimeout("countdown('"+divid+"',"+counttime+")",1000);
	}
	/*******************************/
	</script>
<script>
	countdown("#count_down1","{$stime}");
</script>


 <script>
function sendcode(o){
	$.ajax({
//		url:'/index.php?m=Home&c=User&a=send_validate_code&t='+Math.random(),
		url:'{:U("Home/User/sen_sms_code")}?t='+Math.random(),
		type:'post',
		dataType:'json',
		data:{type:$('#verify-type-selector').val(),send:$('#username').val()},
		success:function(res){
			if(res.status==1){
				timer(o);
			}else{
				$.artTip(res.msg, 800);
			}
		}
	})
}

var wait=180;
function timer(o) { 
	//$('span[data-tips-for="tpcode"]').find('i').addClass('icon');
	//$('span[data-tips-for="tpcode"]').find('i').removeClass('icon-warn');
	//$('span[data-tips-for="tpcode"]').find('.txt').empty();
    if (wait == 0) {  
        o.removeAttribute("disabled");            
        o.value="获取验证码";  
        wait = 180;  
    } else {  
        o.setAttribute("disabled", true);  
        o.value="重新发送(" + wait + ")";  
        wait--;  
        setTimeout(function() {  
          timer(o)  
        }, 1000)  
    }  
}

var is_check = false;
function checkcode(){
	var tpcode = $('#tpcode').val();
	//$('span[data-tips-for="tpcode"]').css('display','inline');
	//$('span[data-tips-for="tpcode"]').find('i').removeClass('icon');
	//$('span[data-tips-for="tpcode"]').find('i').addClass('icon-warn');
	if(tpcode == ''){
		//$('span[data-tips-for="tpcode"]').find('.txt').empty().html('验证码不能为空');
		
				$.artTip('验证码不能为空', 800);
		return;
	}
	if(tpcode.length != 4){
		//$('span[data-tips-for="tpcode"]').find('.txt').empty().html('验证码不正确');
				$.artTip('验证码不正确', 800);
		return;
	}
	
	$.ajax({
		url:'/index.php?m=Home&c=User&a=check_validate_code&t='+Math.random(),
		type:'post',
		dataType:'json',
		data:{code:tpcode,send:$('#username').val()},
		success:function(res){
			if(res.status==1){
				is_check = true;
				//$('span[data-tips-for="tpcode"]').css('display','inline');
				//$('span[data-tips-for="tpcode"]').find('i').removeClass('icon-warn');
				//$('span[data-tips-for="tpcode"]').find('i').addClass('icon-loss');
				//$('span[data-tips-for="tpcode"]').find('.txt').empty();
				window.location.href='/index.php?m=Home&c=User&a=set_pwd&t='+Math.random();
			}else{
				//$('span[data-tips-for="tpcode"]').find('.txt').empty().html(res.msg);
				$.artTip(res.msg, 800);
				//alert('验证码未验证通过');
				return false;				
			}
		}
	})
}

function setpwd(){


	var tpcode = $('#tpcode').val();

	//$('span[data-tips-for="tpcode"]').css('display','inline');
	//$('span[data-tips-for="tpcode"]').find('i').removeClass('icon');
	//$('span[data-tips-for="tpcode"]').find('i').addClass('icon-warn');
	if(tpcode == ''){
		//$('span[data-tips-for="tpcode"]').find('.txt').empty().html('验证码不能为空');
		$.artTip('验证码不能为空', 800);
		return;
	}
	if(tpcode.length != 4){
		//$('span[data-tips-for="tpcode"]').find('.txt').empty().html('验证码不正确');
		$.artTip('验证码不正确', 800);
		return;
	}

	checkcode();
 
}
</script>
</body>
</html>	